package com.tac.common.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class Result<T> {
    @ApiModelProperty("提示信息")
    private String msg;
    @ApiModelProperty("状态码")
    private Integer code;
    private T data;

    public static <T> Result<T> success(T data,String msg){
        Result<T> result = new Result<>();
        result.data=data;
        result.msg=msg;
        result.code=200;
        return result;
    }
    public static <T> Result<T> success(T data,String msg,Integer code){
        Result<T> result = new Result<>();
        result.data=data;
        result.msg=msg;
        result.code=code;
        return result;
    }
    public static <T> Result<T> error(String msg){
        Result result = new Result<>();
        result.msg=msg;
        result.code=500;
        return result;
    }
    public static <T> Result<T> error(String msg,Integer code){
        Result result = new Result<>();
        result.msg=msg;
        result.code=code;
        return result;
    }
}
